// System Unit
// WideString Support

(*************)
(* Interface *)
(*************)
{$IFDEF Include_Modules_Header}

 Type
  PWideString = ^WideString;

 Function _PWCharLen(P: PWideChar): Integer;
 Type RTLProc_PWCharLen = Function(P: PWideChar): Integer;

 Function _WStrLen(Const S: WideString): LongInt;
 Type RTLProc_WStrLen = Function(Const S: WideString): LongInt;

 Function _NewWideString(CharLength: LongInt): Pointer;
 Type RTLProc_NewWideString = Function(CharLength: LongInt): Pointer;

 Procedure _WStrFromPWCharLen(Var Dest: WideString; Source: PWideChar; CharLength: Integer);
 Type RTLProc_WStrFromPWCharLen = Procedure(Var Dest: WideString; Source: PWideChar; CharLength: Integer);

 Procedure _WStrFromWChar(Var Dest: WideString; Source: WideChar);
 Type RTLProc_WStrFromWChar = Procedure(Var Dest: WideString; Source: WideChar);

 Procedure _WStrFromPWChar(Var Dest: WideString; Source: PWideChar);
 Type RTLProc_WStrFromPWChar = Procedure(Var Dest: WideString; Source: PWideChar);

 Procedure _WStrFromWArray(Var Dest: WideString; Source: PWideChar; Length: Integer);
 Type RTLProc_WStrFromWArray = Procedure(Var Dest: WideString; Source: PWideChar; Length: Integer);

 Function _WStrToPWChar(Const S: WideString): PWideChar;
 Type RTLProc_WStrToPWChar = Function(Const S: WideString): PWideChar;

 Procedure _WStrAsg(Var Dest: WideString; Const Source: WideString);
 Type RTLProc_WStrAsg = Procedure(Var Dest: WideString; Const Source: WideString);

 Procedure _WStrLAsg(Var Dest: WideString; Const Source: WideString);
 Type RTLProc_WStrLAsg = Procedure(Var Dest: WideString; Const Source: WideString);

 Function _UniqueStringW(Var Str: WideString): Pointer;
 Type RTLProc_UniqueStringW = Function(Var Str: WideString): Pointer;

 Function _WStrLCmp(Const Left, Right: PWideChar; Len: NativeInt): Integer;
 Type RTLProc_WStrLCmp = Function(Const Left, Right: PWideChar; Len: NativeInt): Integer;

 Function _WStrCmp(Const Left, Right: WideString): Integer;
 Type RTLProc_WStrCmp = Function(Const Left, Right: WideString): Integer;

 Function _WStrEqual(Const Left, Right: WideString): Integer;
 Type RTLProc_WStrEqual = Function(Const Left, Right: WideString): Integer;

 Function _WStrAddRef(Var Str: WideString): Pointer;
 Type RTLProc_WStrAddRef = Function(Var Str: WideString): Pointer;

 Function _WStrClr(Var S): Pointer;
 Type RTLProc_WStrClr = Function(Var S): Pointer;

 Procedure _WStrCat(Var Dest: WideString; Const Source: WideString);
 Type RTLProc_WStrCat = Procedure(Var Dest: WideString; Const Source: WideString);

 Procedure _WStrCat3(Var Dest: WideString; Const Source1, Source2: WideString);
 Type RTLProc_WStrCat3 = Procedure(Var Dest: WideString; Const Source1, Source2: WideString);

 Procedure _WStrCatN(Var Dest: WideString; argCnt: Integer; Const Strs: WideString {...});
 Type RTLProc_WStrCatN = Procedure(Var Dest: WideString; argCnt: Integer; Const Strs: WideString {...});

 Function _WStrCopy(Const S: WideString; Index, Count: Integer): WideString;
 Type RTLProc_WStrCopy = Function(Const S: WideString; Index, Count: Integer): WideString;

 Procedure _WStrDelete(Var S: WideString; Index, Count: Integer);
 Type RTLProc_WStrDelete = Procedure(Var S: WideString; Index, Count: Integer);

 Procedure _WStrInsert(Const Source: WideString; Var Dest: WideString; Index: Integer);
 Type RTLProc_WStrInsert = Procedure(Const Source: WideString; Var Dest: WideString; Index: Integer);

 Procedure _WStrSetLength(Var S: WideString; NewLength: Integer);
 Type RTLProc_WStrSetLength = Procedure(Var S: WideString; NewLength: Integer);

 Procedure _WStrArrayClr(Var StrArray; Count: Integer);
 Type RTLProc_WStrArrayClr = Procedure(Var StrArray; Count: Integer);

 Procedure UniqueString(Var Str: WideString); Inline; Overload;

 //==================
 // RTL Extensions
 //==================
 Type
  TRTLEx_WideString = Record
   _PWCharLen: RTLProc_PWCharLen;
   _WStrLen: RTLProc_WStrLen;
   _NewWideString: RTLProc_NewWideString;
   _WStrFromPWCharLen: RTLProc_WStrFromPWCharLen;
   _WStrFromWChar: RTLProc_WStrFromWChar;
   _WStrFromPWChar: RTLProc_WStrFromPWChar;
   _WStrFromWArray: RTLProc_WStrFromWArray;
   _WStrToPWChar: RTLProc_WStrToPWChar;
   _WStrAsg: RTLProc_WStrAsg;
   _WStrLAsg: RTLProc_WStrLAsg;
   _UniqueStringW: RTLProc_UniqueStringW;
   _WStrLCmp: RTLProc_WStrLCmp;
   _WStrCmp: RTLProc_WStrCmp;
   _WStrEqual: RTLProc_WStrEqual;
   _WStrAddRef: RTLProc_WStrAddRef;
   _WStrClr: RTLProc_WStrClr;
   _WStrCat: RTLProc_WStrCat;
   _WStrCat3: RTLProc_WStrCat3;
   _WStrCatN: RTLProc_WStrCatN;
   _WStrCopy: RTLProc_WStrCopy;
   _WStrDelete: RTLProc_WStrDelete;
   _WStrInsert: RTLProc_WStrInsert;
   _WStrSetLength: RTLProc_WStrSetLength;
   _WStrArrayClr: RTLProc_WStrArrayClr;
  END;

 Procedure RTLExtend_WideString(Var Ex: TRTLEx_WideString);

{$ENDIF Include_Modules_Header}
(******************)
(* Implementation *)
(******************)
{$IFDEF Include_Modules_Implement}

 Function _RTL_PWCharLen(P: PWideChar): Integer;
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL_WStrLen(Const S: WideString): LongInt;
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL_NewWideString(CharLength: LongInt): Pointer;
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_WStrFromPWCharLen(Var Dest: WideString; Source: PWideChar; CharLength: Integer);
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_WStrFromWChar(Var Dest: WideString; Source: WideChar);
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_WStrFromPWChar(Var Dest: WideString; Source: PWideChar);
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_WStrFromWArray(Var Dest: WideString; Source: PWideChar; Length: Integer);
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL_WStrToPWChar(Const S: WideString): PWideChar;
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_WStrAsg(Var Dest: WideString; Const Source: WideString);
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_WStrLAsg(Var Dest: WideString; Const Source: WideString);
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL_UniqueStringW(Var Str: WideString): Pointer;
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL_WStrLCmp(Const Left, Right: PWideChar; Len: NativeInt): Integer;
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL_WStrCmp(Const Left, Right: WideString): Integer;
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL_WStrEqual(Const Left, Right: WideString): Integer;
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL_WStrAddRef(Var Str: WideString): Pointer;
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL_WStrClr(Var S): Pointer;
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_WStrCat(Var Dest: WideString; Const Source: WideString);
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_WStrCat3(Var Dest: WideString; Const Source1, Source2: WideString);
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_WStrCatN(Var Dest: WideString; argCnt: Integer; Const Strs: WideString {...});
  ASM
   JMP _INT_NotImplemented
  END;

 Function _RTL_WStrCopy(Const S: WideString; Index, Count: Integer): WideString;
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_WStrDelete(Var S: WideString; Index, Count: Integer);
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_WStrInsert(Const Source: WideString; Var Dest: WideString; Index: Integer);
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_WStrSetLength(Var S: WideString; NewLength: Integer);
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure _RTL_WStrArrayClr(Var StrArray; Count: Integer);
  ASM
   JMP _INT_NotImplemented
  END;

 Procedure UniqueString(Var Str: WideString);
  BEGIN
   _UniqueStringW(Str);
  END;

 Var
  RTL_PWCharLen: RTLProc_PWCharLen = _RTL_PWCharLen;
  RTL_WStrLen: RTLProc_WStrLen = _RTL_WStrLen;
  RTL_NewWideString: RTLProc_NewWideString = _RTL_NewWideString;
  RTL_WStrFromPWCharLen: RTLProc_WStrFromPWCharLen = _RTL_WStrFromPWCharLen;
  RTL_WStrFromWChar: RTLProc_WStrFromWChar = _RTL_WStrFromWChar;
  RTL_WStrFromPWChar: RTLProc_WStrFromPWChar = _RTL_WStrFromPWChar;
  RTL_WStrFromWArray: RTLProc_WStrFromWArray = _RTL_WStrFromWArray;
  RTL_WStrToPWChar: RTLProc_WStrToPWChar = _RTL_WStrToPWChar;
  RTL_WStrAsg: RTLProc_WStrAsg = _RTL_WStrAsg;
  RTL_WStrLAsg: RTLProc_WStrLAsg = _RTL_WStrLAsg;
  RTL_UniqueStringW: RTLProc_UniqueStringW = _RTL_UniqueStringW;
  RTL_WStrLCmp: RTLProc_WStrLCmp = _RTL_WStrLCmp;
  RTL_WStrCmp: RTLProc_WStrCmp = _RTL_WStrCmp;
  RTL_WStrEqual: RTLProc_WStrEqual = _RTL_WStrEqual;
  RTL_WStrAddRef: RTLProc_WStrAddRef = _RTL_WStrAddRef;
  RTL_WStrClr: RTLProc_WStrClr = _RTL_WStrClr;
  RTL_WStrCat: RTLProc_WStrCat = _RTL_WStrCat;
  RTL_WStrCat3: RTLProc_WStrCat3 = _RTL_WStrCat3;
  RTL_WStrCatN: RTLProc_WStrCatN = _RTL_WStrCatN;
  RTL_WStrCopy: RTLProc_WStrCopy = _RTL_WStrCopy;
  RTL_WStrDelete: RTLProc_WStrDelete = _RTL_WStrDelete;
  RTL_WStrInsert: RTLProc_WStrInsert = _RTL_WStrInsert;
  RTL_WStrSetLength: RTLProc_WStrSetLength = _RTL_WStrSetLength;
  RTL_WStrArrayClr: RTLProc_WStrArrayClr = _RTL_WStrArrayClr;

 Function _PWCharLen(P: PWideChar): Integer;
  ASM
   JMP RTL_PWCharLen
  END;

 Function _WStrLen(Const S: WideString): LongInt;
  ASM
   JMP RTL_WStrLen
  END;

 Function _NewWideString(CharLength: LongInt): Pointer;
  ASM
   JMP RTL_NewWideString
  END;

 Procedure _WStrFromPWCharLen(Var Dest: WideString; Source: PWideChar; CharLength: Integer);
  ASM
   JMP RTL_WStrFromPWCharLen
  END;

 Procedure _WStrFromWChar(Var Dest: WideString; Source: WideChar);
  ASM
   JMP RTL_WStrFromWChar
  END;

 Procedure _WStrFromPWChar(Var Dest: WideString; Source: PWideChar);
  ASM
   JMP RTL_WStrFromPWChar
  END;

 Procedure _WStrFromWArray(Var Dest: WideString; Source: PWideChar; Length: Integer);
  ASM
   JMP RTL_WStrFromWArray
  END;

 Function _WStrToPWChar(Const S: WideString): PWideChar;
  ASM
   JMP RTL_WStrToPWChar
  END;

 Procedure _WStrAsg(Var Dest: WideString; Const Source: WideString);
  ASM
   JMP RTL_WStrAsg
  END;

 Procedure _WStrLAsg(Var Dest: WideString; Const Source: WideString);
  ASM
   JMP RTL_WStrLAsg
  END;

 Function _UniqueStringW(Var Str: WideString): Pointer;
  ASM
   JMP RTL_UniqueStringW
  END;

 Function _WStrLCmp(Const Left, Right: PWideChar; Len: NativeInt): Integer;
  ASM
   JMP RTL_WStrLCmp
  END;

 Function _WStrCmp(Const Left, Right: WideString): Integer;
  ASM
   JMP RTL_WStrCmp
  END;

 Function _WStrEqual(Const Left, Right: WideString): Integer;
  ASM
   JMP RTL_WStrEqual
  END;

 Function _WStrAddRef(Var Str: WideString): Pointer;
  ASM
   JMP RTL_WStrAddRef
  END;

 Function _WStrClr(Var S): Pointer;
  ASM
   JMP RTL_WStrClr
  END;

 Procedure _WStrCat(Var Dest: WideString; Const Source: WideString);
  ASM
   JMP RTL_WStrCat
  END;

 Procedure _WStrCat3(Var Dest: WideString; Const Source1, Source2: WideString);
  ASM
   JMP RTL_WStrCat3
  END;

 Procedure _WStrCatN(Var Dest: WideString; argCnt: Integer; Const Strs: WideString {...});
  ASM
   JMP RTL_WStrCatN
  END;

 Function _WStrCopy(Const S: WideString; Index, Count: Integer): WideString;
  ASM
   JMP RTL_WStrCopy
  END;

 Procedure _WStrDelete(Var S: WideString; Index, Count: Integer);
  ASM
   JMP RTL_WStrDelete
  END;

 Procedure _WStrInsert(Const Source: WideString; Var Dest: WideString; Index: Integer);
  ASM
   JMP RTL_WStrInsert
  END;

 Procedure _WStrSetLength(Var S: WideString; NewLength: Integer);
  ASM
   JMP RTL_WStrSetLength
  END;

 Procedure _WStrArrayClr(Var StrArray; Count: Integer);
  ASM
   JMP RTL_WStrArrayClr
  END;

 //==================
 // RTL Extensions
 //==================

 Procedure RTLExtend_WideString(Var Ex: TRTLEx_WideString);
  BEGIN
   _INT_RTL_DoEx(@RTL_PWCharLen, @Ex._PWCharLen);
   _INT_RTL_DoEx(@RTL_WStrLen, @Ex._WStrLen);
   _INT_RTL_DoEx(@RTL_NewWideString, @Ex._NewWideString);
   _INT_RTL_DoEx(@RTL_WStrFromPWCharLen, @Ex._WStrFromPWCharLen);
   _INT_RTL_DoEx(@RTL_WStrFromWChar, @Ex._WStrFromWChar);
   _INT_RTL_DoEx(@RTL_WStrFromPWChar, @Ex._WStrFromPWChar);
   _INT_RTL_DoEx(@RTL_WStrFromWArray, @Ex._WStrFromWArray);
   _INT_RTL_DoEx(@RTL_WStrToPWChar, @Ex._WStrToPWChar);
   _INT_RTL_DoEx(@RTL_WStrAsg, @Ex._WStrAsg);
   _INT_RTL_DoEx(@RTL_WStrLAsg, @Ex._WStrLAsg);
   _INT_RTL_DoEx(@RTL_UniqueStringW, @Ex._UniqueStringW);
   _INT_RTL_DoEx(@RTL_WStrLCmp, @Ex._WStrLCmp);
   _INT_RTL_DoEx(@RTL_WStrCmp, @Ex._WStrCmp);
   _INT_RTL_DoEx(@RTL_WStrEqual, @Ex._WStrEqual);
   _INT_RTL_DoEx(@RTL_WStrAddRef, @Ex._WStrAddRef);
   _INT_RTL_DoEx(@RTL_WStrClr, @Ex._WStrClr);
   _INT_RTL_DoEx(@RTL_WStrCat, @Ex._WStrCat);
   _INT_RTL_DoEx(@RTL_WStrCat3, @Ex._WStrCat3);
   _INT_RTL_DoEx(@RTL_WStrCatN, @Ex._WStrCatN);
   _INT_RTL_DoEx(@RTL_WStrCopy, @Ex._WStrCopy);
   _INT_RTL_DoEx(@RTL_WStrDelete, @Ex._WStrDelete);
   _INT_RTL_DoEx(@RTL_WStrInsert, @Ex._WStrInsert);
   _INT_RTL_DoEx(@RTL_WStrSetLength, @Ex._WStrSetLength);
   _INT_RTL_DoEx(@RTL_WStrArrayClr, @Ex._WStrArrayClr);
  END;

{$ENDIF Include_Modules_Implement}
(******************)
(* Initialization *)
(******************)
{$IFDEF Include_Modules_Initialize}
{$ENDIF Include_Modules_Initialize}
(****************)
(* Finalization *)
(****************)
{$IFDEF Include_Modules_Finalize}
{$ENDIF Include_Modules_Finalize}
